<?php
namespace app\models;

use core\base\Model;

class Student extends Model
{
    protected $tables = 'student';

    public function __construct()
    {
        parent::__construct($this->tables);
    }

    public function hasOneClassroom()
    {
        return $this->hasOne(Classroom::class, 'id', 'cid');
    }

    public function getSnameAttr($sname)
    {
        //可以对 $sname 进行处理
        return '勇敢的'.$sname;
//        return $sname;
    }
//
//    public function getAgeAttr($age)
//    {
//        return $age+2;
//    }

    public function getStudentInfo()
    {
        return $this->hasMany(Classroom::class, School::class);
    }

}